import { RouterMap } from '../utils/constants';

export function useNav(context) {
  const to = (name, query = {}) => {
    context.root.$router.push({ name, query });
  };

  const toParam = (name, params = {}) => {
    context.root.$router.push({ name, params });
  }

  const toHome = () => {
    to(RouterMap.Home);
  };

  const getQuery = (key) => {
    if (key) {
      return context.root.$route.query[key];
    }
    return context.root.$route.query;
  };

  return { to, toHome, getQuery, toParam };
}
